home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / m17n / th-pattachote.mim < prev    next >
Text File  |  2009-04-29  |  6KB  |  307 lines

  1. ;; th-pattachote.mim -- Thai input method with Pattachote keyboard layout
  2. ;; Copyright (C) 2006, 2007
  3. ;;   National Institute of Advanced Industrial Science and Technology (AIST)
  4. ;;   Registration Number H15PRO112
  5.  
  6. ;; This file is part of the m17n database; a sub-part of the m17n
  7. ;; library.
  8.  
  9. ;; The m17n library is free software; you can redistribute it and/or
  10. ;; modify it under the terms of the GNU Lesser General Public License
  11. ;; as published by the Free Software Foundation; either version 2.1 of
  12. ;; the License, or (at your option) any later version.
  13.  
  14. ;; The m17n library is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. ;; Lesser General Public License for more details.
  18.  
  19. ;; You should have received a copy of the GNU Lesser General Public
  20. ;; License along with the m17n library; if not, write to the Free
  21. ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  22. ;; 02110-1301, USA.
  23.  
  24. (input-method th pattachote)
  25.  
  26. (description "Thai input method simulating the Pattachote keyboard
  27. with WTT 2.0 input sequence correction.
  28. The correction algorithm follows the one shown in the following 
  29.   <http://linux.thai.net/~thep/th-xim/>
  30. ")
  31.  
  32. (title "α╕ù")
  33.  
  34. (variable
  35.  (level (_"Acceptance level
  36. The level of character sequence acceptance defined in WTT 2.0.
  37. 0 accepts any key sequence.  2 accepts only orthographic ones.
  38. 1 is somewhere between.")
  39.     1 0 1 2))
  40.  
  41. (include (th kesmanee) macro)
  42.  
  43. (map
  44.  (map
  45.   ("!" "+")
  46.   ("\"" "α╕æ")
  47.   ("#" "/")
  48.   ("$" ",")
  49.   ("%" "?")
  50.   ("&" "_")
  51.   ("'" "α╕é")
  52.   ("(" "(")
  53.   (")" ")")
  54.   ("*" ".")
  55.   ("+" "%")
  56.   ("," "α╕░")
  57.   ("-" "α╣æ")
  58.   ("." "α╕ê")
  59.   ("/" "α╕₧")
  60.   ("0" "α╣É")
  61.   ("1" "=")
  62.   ("2" "α╣Æ")
  63.   ("3" "α╣ô")
  64.   ("4" "α╣ö")
  65.   ("5" "α╣ò")
  66.   ("6" "α╕╣")
  67.   ("7" "α╣ù")
  68.   ("8" "α╣ÿ")
  69.   ("9" "α╣Ö")
  70.   (":" "α╕å")
  71.   (";" "α╣ä")
  72.   ("<" "α╕ƒ")
  73.   ("=" "α╣û")
  74.   (">" "α╕ë")
  75.   ("?" "α╕¼")
  76.   ("@" "\"")
  77.   ("A" "α╣ï")
  78.   ("B" "α╕║")
  79.   ("C" "α╕É")
  80.   ("D" "α╕│")
  81.   ("E" "α╣å")
  82.   ("F" "α╕ô")
  83.   ("G" "α╣î")
  84.   ("H" "α╕╖")
  85.   ("I" "α╕ï")
  86.   ("J" "α╕£")
  87.   ("K" "α╕è")
  88.   ("L" "α╣é")
  89.   ("M" "α╕«")
  90.   ("N" "α╕¿")
  91.   ("O" "α╕û")
  92.   ("P" "α╕Æ")
  93.   ("Q" "α╣è")
  94.   ("R" "α╕ì")
  95.   ("S" "α╕ÿ")
  96.   ("T" "α╕⌐")
  97.   ("U" "α╕¥")
  98.   ("V" "α╕á")
  99.   ("W" "α╕ñ")
  100.   ("X" "α╕Å")
  101.   ("Y" "α╕╢")
  102.   ("Z" "α╕Ä")
  103.   ("[" "α╣â")
  104.   ("\\" "α╣à")
  105.   ("]" "α╕î")
  106.   ("^" "α╕╕")
  107.   ("_" "-")
  108.   ("`" "_")
  109.   ("a" "α╣ë")
  110.   ("b" "α╕┤")
  111.   ("c" "α╕Ñ")
  112.   ("d" "α╕ç")
  113.   ("e" "α╕ó")
  114.   ("f" "α╕ü")
  115.   ("g" "α╕▒")
  116.   ("h" "α╕╡")
  117.   ("i" "α╕í")
  118.   ("j" "α╕▓")
  119.   ("k" "α╕Ö")
  120.   ("l" "α╣Ç")
  121.   ("m" "α╕¬")
  122.   ("n" "α╕ä")
  123.   ("o" "α╕º")
  124.   ("p" "α╣ü")
  125.   ("q" "α╣ç")
  126.   ("r" "α╕¡")
  127.   ("s" "α╕ù")
  128.   ("t" "α╕ú")
  129.   ("u" "α╕ö")
  130.   ("v" "α╕½")
  131.   ("w" "α╕ò")
  132.   ("x" "α╕¢")
  133.   ("y" "α╣ê")
  134.   ("z" "α╕Ü")
  135.   ("{" "α╕»")
  136.   ("|" "α╣ì")
  137.   ("}" "α╕ª")
  138.   ("~" "α╕┐")))
  139.  
  140. (state
  141.  
  142.  (init
  143.   (map
  144.    (delete @<)
  145.    (pushback 1)
  146.    (shift main)))
  147.  
  148.  (main
  149.   (map
  150.    (set x @-3)
  151.    (set y @-2)
  152.    (set z @-1)
  153.  
  154.    (set arg1 y)
  155.    (set arg2 z)
  156.    (cp)
  157.    (cond
  158.     ((= ret 1)) ;; CP(y,z) succeeded.
  159.     (1
  160.      (ac)
  161.      (cond
  162.       ((= ret 1)) ;; AC(y,z) succeeded.
  163.       (1
  164.        ;; WTT-based input sequence correction starts here.
  165.  
  166.        ;; begin
  167.        ;; if CP(x,z) then
  168.        (set arg1 x)
  169.        (set arg2 z)
  170.        (cp)
  171.        (cond
  172.     ((= ret 1)
  173.  
  174.      ;; if CP(z,y) then
  175.      (set arg1 z)
  176.      (set arg2 y)
  177.      (cp)
  178.      (cond
  179.       ((= ret 1)
  180.  
  181.        ;; reorder(y -> zy)
  182.        (delete @-2)
  183.        (insert z)
  184.        (insert y))
  185.  
  186.       ;; elif CP(x,y) then
  187.       (1
  188.        (set arg1 x)
  189.        (set arg2 y)
  190.        (cp)
  191.        (cond
  192.         ((= ret 1)
  193.  
  194.          ;; replace(y -> z)
  195.          (delete @-2)
  196.          (insert z))
  197.  
  198.         ;; elif y is FV1 and z is TONE then
  199.         ((& (| (= y 0x0E30) (= y 0x0E32) (= y 0x0E33))
  200.         (>= z 0x0E48)
  201.         (<= z 0x0E4B))
  202.  
  203.          ;; reorder(y -> zy)
  204.          (delete @-2)
  205.          (insert z)
  206.          (insert y))
  207.  
  208.         ;; else
  209.         ;; reject(z)
  210.         (1
  211.          (delete @-1))
  212.  
  213.         ;;endif
  214.         ))))
  215.  
  216.     ;; elif AC(x,z) then
  217.     (1
  218.      (set arg1 x)
  219.      (set arg2 z)
  220.      (ac)
  221.      (cond
  222.       ((& (= ret 1)
  223.           ;; Only Thai characters should be replaced.
  224.           (& (>= y 0x0E01) (<= y 0x0E5B))
  225.           (& (>= z 0x0E01) (<= z 0x0E5B)))
  226.  
  227.        ;; replace(y -> z)
  228.        (delete @-2)
  229.        (insert z))
  230.  
  231.       ;; else
  232.       ;; reject(z)
  233.       (1
  234.        (delete @-1))
  235.  
  236.       ;; endif
  237.       )))
  238.        ;; end
  239.  
  240.        ))))
  241.  
  242.    ;; Now we commit the preedit chars that are fixed.
  243.    (set w @-1)
  244.    (cond
  245.     ;; If surrounding text is supported, commit the only char in preedit.
  246.     ((> @-0 -2)
  247.      (commit))
  248.  
  249.     ;; If the last char is CTRL or NON, we can commit everything.
  250.     ((| (& (>= w 0x0000) (<= w 0x0E00))
  251.     (= w 0x0E2F)
  252.     (= w 0x0E3F)
  253.     (= w 0x0E46)
  254.     (>= w 0x0E4F))
  255.      (commit))
  256.  
  257.     ;; If the last char is CONS, we can commit everything but the last
  258.     ;; unless the second last is FV3.
  259.     ((| (& (>= w 0x0E01) (<= w 0x0E23))
  260.     (= w 0x0E25)
  261.     (& (>= w 0x0E27) (<= w 0x0E2E)))
  262.      (cond
  263.       ((| (= @-2 0x0E24) (= @-2 0x0E26))
  264.        ; not commit yet
  265.        )
  266.       (1
  267.        (delete @-1)
  268.        (commit)
  269.        (insert w))))
  270.  
  271.     ;; If the last char is LV, FV2 or FV3, we can commit
  272.     ;; everything but the last.
  273.     ((| (& (>= w 0x0E40) (<= w 0x0E45))
  274.     (= w 0x0E24)
  275.     (= w 0x0E26))
  276.      (delete @-1)
  277.      (commit)
  278.      (insert w))
  279.  
  280.     ;; If the last char is FV1 (excluding AM) and ...
  281.     ((| (= w 0x0E30) (= w 0x0E32))
  282.      (delete @-1)
  283.      (set v @-1)
  284.      (cond
  285.  
  286.       ;; ... the before last is CONS, we can commit other than the
  287.       ;; last two.
  288.       ((| (& (>= v 0x0E01) (<= v 0x0E23))
  289.       (= v 0x0E25)
  290.       (& (>= v 0x0E27) (<= v 0x0E2E)))
  291.        (delete @-1)
  292.        (commit)
  293.        (insert v)
  294.        (insert w))
  295.  
  296.       ;; ... else if the before last is not CONS, we can commit
  297.       ;; everything but the last.
  298.       (1
  299.        (commit)
  300.        (insert w))))
  301.     ))))
  302.  
  303. ;; Local Variables:
  304. ;; coding: utf-8
  305. ;; mode: emacs-lisp
  306. ;; End:
  307.